<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .box {
      width: 150px;
      height: 150px;
      background-color: aquamarine;
    }
  </style>
</head>

<body>
  <div id="app">
    <!-- v-show指令   控制元素显示隐藏 -->
    <button @click="isShow = !isShow">{{isShow ? "隐藏":"显示" }}</button>
    <!-- v-text 向元素中添加文本内容    与{{}}语法作用一样 -->
    <div class="box" v-show="isShow" v-text="msg"></div>
    <!-- v-html   向元素中添加html文本（富文本）可以被解析-->
    <div v-html="music" @click="alert()"></div>
  </div>
  <script src="../vue.js"></script>
  <script>
    const vm = new Vue({
      el: '#app',
      data: {
        msg: '拿着锤子的约德尔人',
        isShow: true,
        music: '<h3>拿着约德尔人的锤子</h3>',
        arr1: ['a1','2'],
        arr2: ['3','5']
      },
      //将方法放在methods中，只是便于管理，方法还是直接挂载到vue实例上的
      methods: {
        sum(num1, num2){
          console.log(num1 + num2);
        },
        alert(){
          confirm('你是sb吗？')
        }
      },
      mounted(){
        const arr = (this.arr1).concat(this.arr2);
        console.log(arr);
        console.log(this.arr1);
        console.log(this.arr2);
      }
    })
    vm.sum(1,10)
  </script>
</body>

</html>